package com.van.bo.badwrting;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MessageDao extends ElasticsearchRepository<Message, String> {
    Page<Message> findAll(Pageable pageable);


    Iterable<Message> findAll(Sort sort);

    @Query("{\"match\": {\"username\": {\"query\": \"?0\"}}}")
    List<Message> findByUsername(String username);

    List<Message> findByAgeBetween(Long mix, Long max);

    Long countByAgeBetween(Long mix, Long max);
}